Shapley values are a method from cooperative game theory that allows us to measure each feature’s individual contribution to a model’s prediction.Think of the model’s prediction as a “reward” that needs to be fairly distributed among “players” (the features). By calculating Shapley values, we determine how much each feature contributed to the prediction by seeing how the prediction changes when we add or remove that feature from various subsets of features.
To calculate Shapley values, we use a value function representing the model’s prediction based on any subset of features. This function lets us measure how much the prediction changes when a particular feature is added to a subset, capturing the marginal contribution of each feature.
Because the model’s prediction depends on all features—even those not in the subset we’re focusing on—we use marginalization to account for the remaining features by averaging their possible values. This lets us isolate the specific impact of the features in our subset.
The Shapley value for a feature is computed by averaging its marginal contributions across all possible subsets of features. This ensures that each feature’s contribution is fairly represented. However, calculating Shapley values for all subsets becomes computationally intense as the number of features increases since there are exponentially many subsets to consider.
To simplify this, we use Monte Carlo sampling to approximate Shapley values by randomly sampling subsets of features rather than evaluating them all. This method involves comparing the model’s predictions on random subsets with and without a specific feature and then averaging these differences across samples of records to estimate the feature’s contribution.
When estimating Shapley values through sampling, it’s important to evaluate how close these approximations are to the true values. Hoeffding’s inequality helps us by providing a statistical guarantee: it bounds the probability that the sampled-based Shapley values will deviate from the true Shapley values by more than a specified amount.
By applying Hoeffding’s inequality, we can establish that, for a sufficiently large number of samples \(K\), the probability that our Shapley value estimate deviates from the actual value by more than a small error margin \(\epsilon\) becomes very small.
KernelExplainer estimates Shapley values by sampling subsets and comparing predictions with and without each feature. Although KernelExplainer is flexible, it assumes feature independence, which can lead to slight biases when features are correlated: it uses marginal sampling rather than conditional sampling and consequently, the Shapley values calculated with KernelExplainer may be biased by its assumption that features are independent. Given our experiment’s natural grouping of features, Owen values may have been a more suitable choice from the start, as they can account for feature interactions.
Like Shapley values, Owen values aim to fairly distribute the model’s prediction among features. However, instead of evaluating features individually, Owen values allow us to create coalitions of features that act together.
-
To calculate Owen values:
- We first form coalitions based on related features.
- Then, we treat each coalition as a single “player” in the cooperative game, calculating the Shapley value for each coalition.
- Finally, within each coalition, we distribute the coalition’s Shapley value among individual features based on their individual contributions within the coalition.
This two-step process (calculating Shapley values for coalitions, then distributing within each coalition) ensures that Owen values accurately reflect both individual and collective contributions, especially when features are interdependent.
In machine learning explainability, choosing between Shapley and Owen values is a strategic decision. Shapley values excel in analyzing independent contributions, while Owen values are better suited for capturing interactions within feature groups. This distinction is crucial when dependencies exist, as Owen values provide a more accurate reflection of joint influences.
When features are correlated, the use of KernelExplainer from the SHAP library can lead to biased results, since this method assumes all features are independent. In cases where features naturally form groups, Owen values offer a better alternative by accurately capturing feature interactions through grouped coalitions. Combining Shapley and Owen values is beneficial in complex models with independent and interdependent features.